﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace GMS.Dinasty.DAL
{
    public class DAApplication
    {
        public DAApplication(SqlConnection connection)
        {
            _connection = connection;
        }
        private SqlConnection _connection;
         
        public DataTable ApplicationsList()
        { 
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand("select da.Id as id, U.SName as contractor, dd.Caption as caption from 	DApplications da,	Users U, DDistributor dd where 	da.IdUser = U.IdUser and da.IdDistributor = dd.Id");
            da.SelectCommand.Connection = _connection;

            DataTable dt = new DataTable("ApplicationsList");
            da.Fill(dt);
            return dt;
        }

        public DataTable ApplicationsContent()
        { 
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand("select * from DApplicationsContent");
            da.SelectCommand.Connection = _connection;

            DataTable dt = new DataTable("ApplicationsContent");
            da.Fill(dt);
            return dt;
        }
        
    }
}
